/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cratos.xxgram.platf.message;

import com.cratos.xxgram.platf.base.UserInfo;
import java.io.Serializable;
import java.net.InetSocketAddress;
import java.util.Collection;
import javax.persistence.Column;
import org.redkale.net.http.WebSocketUserAddress;
import org.redkale.util.Comment;
import org.redkale.util.Reproduce;

/**
 *
 * @author SquRab
 */
@Comment("在线用户信息")
public class UserOnLine implements WebSocketUserAddress {

   protected int userid;  //用户ID
   
    private static final Reproduce<UserOnLine, UserInfo> reproduce = Reproduce.create(UserOnLine.class, UserInfo.class);
    
    @Column(length = 128, comment = "[用户昵称]")
    protected String username = "";  //用户昵称

    @Column(comment = "[用户类型]")
    protected short type;    //用户类型 （前端不可见）

    @Column(length = 128, comment = "密码")
    protected String password = ""; //密码（前端不可见） 数据库存放的密码规则为: HEX-SHA1( HEX-MD5( HEX-MD5(明文)+"-REDKALE" ) +"-REDKALE" )

    @Column(length = 128, comment = "[用户账号]")
    protected String account = "";  //用户账号（前端不可见）

    @Column(length = 128, comment = "[手机号码]")
    protected String mobile = "";  //手机号码（前端不可见）

    @Column(length = 1024, comment = "头像")
    protected String face = "";

    @Column(length = 255, comment = "融云token")
    protected String rytoken = "";  //融云token （前端不可见）

    @Column(comment = "融云token更新时间")
    protected long rytime;

    @Column(comment = "个人信息更新时间")
    protected long infotime;
    
    @Column(length = 16, comment = "APP的设备系统(小写); android/ios/web/wap")
    protected String appos = "";//APP的设备系统 （前端不可见） 

    @Column(length = 255, comment = "APP的设备ID")
    protected String apptoken = "";  //APP的设备ID （前端不可见） 通常用于IOS的APNS推送

    @Column(comment = "[状态]: 10:正常;20:待审批;30:审批不通过;40:冻结;50:隐藏;60:关闭;70:过期;80:删除;")
    protected short status;    //状态 （前端不可见）  值见BaseEntity的STATUS常量

    @Column(comment = "[性别]：2：男； 4:女；")
    protected short gender; //性别; 2:男;  4:女; 值见BaseEntity的GENDER常量

    @Column(comment = "ecdh加密私钥")
    protected String ecdhprivkey;
    
    @Column(comment = "ecdh加密公钥")
    protected String ecdhpubkey;
    
     @Column(comment = "上一次ecdh加密私钥")
    protected String preecdhprivkey;
    
    @Column(comment = "上一次ecdh加密公钥")
    protected String preecdhpubkey;

    @Column(comment = "WS连接的地址")
    protected InetSocketAddress sncpAddress;
    
    public int getUserid() {
        return userid;
    }

    public void setUserid(int userid) {
        this.userid = userid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public short getType() {
        return type;
    }

    public void setType(short type) {
        this.type = type;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getFace() {
        return face;
    }

    public void setFace(String face) {
        this.face = face;
    }

    public String getRytoken() {
        return rytoken;
    }

    public void setRytoken(String rytoken) {
        this.rytoken = rytoken;
    }

    public long getRytime() {
        return rytime;
    }

    public void setRytime(long rytime) {
        this.rytime = rytime;
    }

    public long getInfotime() {
        return infotime;
    }

    public void setInfotime(long infotime) {
        this.infotime = infotime;
    }

    public String getAppos() {
        return appos;
    }

    public void setAppos(String appos) {
        this.appos = appos;
    }

    public String getApptoken() {
        return apptoken;
    }

    public void setApptoken(String apptoken) {
        this.apptoken = apptoken;
    }

    public short getStatus() {
        return status;
    }

    public void setStatus(short status) {
        this.status = status;
    }

    public short getGender() {
        return gender;
    }

    public void setGender(short gender) {
        this.gender = gender;
    }

    public String getEcdhprivkey() {
        return ecdhprivkey;
    }

    public void setEcdhprivkey(String ecdhprivkey) {
        this.ecdhprivkey = ecdhprivkey;
    }

    public String getEcdhpubkey() {
        return ecdhpubkey;
    }

    public void setEcdhpubkey(String ecdhpubkey) {
        this.ecdhpubkey = ecdhpubkey;
    }

    public String getPreecdhprivkey() {
        return preecdhprivkey;
    }

    public void setPreecdhprivkey(String preecdhprivkey) {
        this.preecdhprivkey = preecdhprivkey;
    }

    public String getPreecdhpubkey() {
        return preecdhpubkey;
    }

    public void setPreecdhpubkey(String preecdhpubkey) {
        this.preecdhpubkey = preecdhpubkey;
    }

    @Override
    public Serializable userid() {
        return userid;    
    }

    @Override
    public InetSocketAddress sncpAddress() {
        return sncpAddress;
    }

    @Override
    public Collection<InetSocketAddress> sncpAddresses() {
        return null;
    }

    public UserOnLine(UserInfo userInfo, InetSocketAddress sncpAddress) {
        UserOnLine self = this;
        reproduce.apply(self, userInfo);
        this.sncpAddress = sncpAddress;
    }

}
